<?php
/**
 * Created by PhpStorm.
 * User: Silence
 * Date: 2017-07-03
 * Time: 15:37
 */

namespace App\Http\Controllers\Index;

use App\Base\BaseFunc;
use App\Http\Controllers\Controller;
use App\Model\DBTables;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;

class IndexController extends Controller
{
    public function loginAD()
    {
        $data['list'] = DB::table('ad')
            ->where('ad_login',1)
            ->orderby('ad_id','desc')
            ->paginate(5);
        return view('/index.loginAD',$data);
    }

    public function first()
    {
        $data['adData'] = DB::table('ad')
            ->where('ad_floor',1)
            ->orderby('ad_id','desc')
            ->get();
        return view("/index.first",$data);
    }

    public function index($id)
    {
        $data['adData'] = DB::table('ad')
            ->where('ad_floor',$id)
            ->orderby('ad_id','desc')
            ->paginate(8);
        $data['adFirst'] = DB::table('ad')
            ->where('ad_floor',$id)
            ->orderby('ad_id','desc')
            ->first();
        $data['gameJPGs'] = DB::table('game_jpg')
            ->where('game_jpg_status',1)
            ->where('game_jpg_floor',$id)
            ->orderby('game_jpg_id','desc')
            ->paginate(4);
        $data['userJPGs'] = DB::table('user_jpg')
            ->where('user_jpg_status',1)
            ->where('user_jpg_floor',$id)
            ->orderby('user_jpg_id','desc')
            ->paginate(4);
        $data['expData'] = DB::table('user_exp')
            ->where('user_exp_status',1)
            ->where('user_exp_floor',$id)
            ->orderby('user_exp_id','desc')
            ->paginate(4);
        $data['articleData'] = DB::table('user_article')
            ->where('user_article_status',1)
            ->where('user_article_floor',$id)
            ->orderby('user_article_id','desc')
            ->paginate(4);
        $data['glData'] = DB::table('game_gl')
            ->where('game_gl_floor',$id)
            ->orderby('game_gl_id','desc')
            ->paginate(4);
        session(['nowFloor' => $id]);
        if ($id == 1)
        {
            return view("/index.newIndex.index",$data);
        }
        elseif ($id == 2)
        {
            return view("/index.newIndex1.index",$data);
        }
        elseif ($id == 3)
        {
            return view("/index.newIndex2.index",$data);
        }
    }

    public function newIndex()
    {
        return view("/index.newIndex");
    }

    public function adList($id,DBTables $DBTables)
    {
        $data = $DBTables->listDB('ad',$id);
        session(["nowFloor" => $id]);
        if ($id == 1)
        {
            return view("/index.newIndex.list",$data);
        }
        elseif ($id == 2)
        {
            return view("/index.newIndex1.list",$data);
        }
        elseif ($id == 3)
        {
            return view("/index.newIndex2.list",$data);
        }
    }

    public function adsInfo($id,DBTables $DBTables)
    {
        $data = $DBTables->infoDB('ad',$id);
        session(["nowFloor" => $id]);
        if ($id == 1)
        {
            return view("/index.newIndex.info",$data);
        }
        elseif ($id == 2)
        {
            return view("/index.newIndex1.info",$data);
        }
        elseif ($id == 3)
        {
            return view("/index.newIndex2.info",$data);
        }
    }


}